<template>
  <div id="app">
    <basedrag-btn></basedrag-btn>
    <div class="ifscreen" v-if="ifScreen">请将手机竖屏使用</div>
    <!-- <keep-alive >
      <router-view/>
    </keep-alive> -->
    <router-view v-else/>
  </div>
</template>
<script>
export default {
  name: 'app',
  data() {
    return {
      // _home:"",
      ifScreen:false,
      info: {
        kyyts: '',
        mtkfs: ''
      }
    };
  },
  mounted(){
    var _this = this
  var u = navigator.userAgent;
  var flag;
  var myFunction;
  var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  if (isIOS) {
    document.body.addEventListener('focusin', () => {  //软键盘弹起事件
      flag = true;
      clearTimeout(myFunction);
    })
    document.body.addEventListener('focusout', () => { //软键盘关闭事件
      flag = false;
      if (!flag) {
        myFunction = setTimeout(function () {
          window.scrollTo({ top: 0, left: 0, behavior: "smooth" })
        }, 200);
      } else {
        return
      }
    })
  } else {
    return
  }
    window.addEventListener("orientationchange",
    function(event)
    {
      if (window.orientation == 0 || window.orientation == 180) {
    //
    //  根据event.orientation|screen.orientation.angle等于0|180、90|-90度来判断横竖屏
        _this.ifScreen = false;
        _this._home = false;
        return false;
      }else if (window.orientation == 90 || window.orientation == -90) {
        _this.ifScreen = true;
        _this._home = true;
        return false;
      }
    },
    false);
  },

};
</script>

<style>
.ifscreen{
  color: #999;
  text-align: center;
  font-size: 1rem;
  position: relative;
  z-index: 101;
  top: 45%;
}
</style>
